import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
import { ref, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import dayjs from 'dayjs';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '序号',
    align: 'center',
    dataIndex: 'index',
    width: 60,
    customRender: ({ index }) => index + 1,
  },
   {
    title: '客户姓名',
    align:"center",
    dataIndex: 'customerName'
   },
   {
    title: '负责人姓名',
    align:"center",
    dataIndex: 'principalName'
   },
   {
    title: '一级分组',
    align:"center",
    dataIndex: 'group1_dictText'
   },
   {
    title: '二级分组',
    align:"center",
    dataIndex: 'group2_dictText'
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "客户姓名",
      field: "customerName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "负责人编号",
      field: "principalId",
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户姓名',
    field: 'customerName',
    component: 'Input',
  },
  {
    label: '负责人姓名',
    field: 'principalName',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '一级分组',
    field: 'group1',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"group1"
     },
    // 移除必填验证，改为可选字段
  },
  {
    label: '二级分组',
    field: 'group2',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"group2"
     },
    // 移除必填验证，改为可选字段
  },
  // {
  //   label: '逻辑删除标志',
  //   field: 'isDeleted',
  //   component: 'InputNumber',
  // },
  {
    label: '创建日期',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      disabled: true
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const followPlanColumns: JVxeColumn[] = [
    {
      title: '跟进计划ID',
      key: 'followPlanId',
      type: JVxeTypes.input,
      width:"120px",
      placeholder: '请输入${title}',
      defaultValue:'',
      hidden: true, // 隐藏此列，但保留字段
    },
    {
      title: '跟进计划信息',
      key: 'followUpText',
      type: JVxeTypes.textarea,
      width:"400px",
      placeholder: '请输入${title}',
      defaultValue:'',
      options: {
        height: 80,
        autoSize: { minRows: 3, maxRows: 6 }
      }
    },
    {
      title: '文件操作',
      key: 'followPlanFile',
      type: JVxeTypes.slot,
      width: '150px',
      placeholder: '请上传文件',
      defaultValue: '',
      slotName: 'followPlanFile',
      align: 'center',
    },
    {
      title: '创建日期',
      key: 'createTime',
      type: JVxeTypes.date,
      width: '150px',
      placeholder: '请输入${title}',
      defaultValue: '',
      disabled: true,
    },
    {
      title: '操作',
      key: 'action',
      type: JVxeTypes.slot,
      width: '100px',
      fixed: 'right',
      slotName: 'followPlanAction',
      align: 'center',
    },
  ]
export const followUpContentColumns: JVxeColumn[] = [
    {
      title: '跟进记录ID',
      key: 'followUpContentId',
      type: JVxeTypes.input,
      width:"120px",
      placeholder: '请输入${title}',
      defaultValue:'',
      hidden: true, // 隐藏此列，但保留字段
    },
    {
      title: '客户标签',
      key: 'customerClassification',
      type: JVxeTypes.select,
      options:[],
      dictCode:"customer_classification",
      width:"150px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '跟进内容',
      key: 'followUpContent',
      type: JVxeTypes.input,
      width:"300px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '跟进进度',
      key: 'progress',
      type: JVxeTypes.input,
      width:"150px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '跟进时间',
      key: 'followUpTime',
      type: JVxeTypes.date,
      width:"150px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '文件操作',
      key: 'followUpContentFile',
      type: JVxeTypes.slot,
      width: '150px',
      placeholder: '请上传文件',
      defaultValue: '',
      slotName: 'followUpContentFile',
      align: 'center',
    },
    {
      title: '操作',
      key: 'action',
      type: JVxeTypes.slot,
      width: '100px',
      fixed: 'right',
      slotName: 'followUpContentAction',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  customerName: {title: '客户姓名',order: 0,view: 'text', type: 'string',},
  principalName: {title: '负责人姓名',order: 2,view: 'text', type: 'string',},
  group1: {title: '一级分组',order: 3,view: 'list', type: 'string',dictCode: 'group1',},
  group2: {title: '二级分组',order: 4,view: 'list', type: 'string',dictCode: 'group2',},
  isDeleted: {title: '逻辑删除标志',order: 5,view: 'number', type: 'number',},
  createTime: {title: '创建日期',order: 6,view: 'date', type: 'string',},
  //子表高级查询
  followPlan: {
    title: '跟进计划信息',
    view: 'table',
    fields: {
        followUpText: {title: '跟进计划信息',order: 0,view: 'text', type: 'string',},
        followPlanFile: {title: '跟进计划文件',order: 1,view: 'text', type: 'string',},
        isDeleted: {title: '逻辑删除标志',order: 2,view: 'number', type: 'number',},
        updateBy: {title: '更新人',order: 3,view: 'text', type: 'string',},
        updateTime: {title: '更新时间',order: 4,view: 'date', type: 'string',},
        createTime: {title: '创建日期',order: 5,view: 'date', type: 'string',},
    }
  },
  followUpContent: {
    title: '跟进记录信息',
    view: 'table',
    fields: {
        customerClassification: {title: '客户标签',order: 0,view: 'list', type: 'string',dictCode: 'customer_classification',},
        followUpContent: {title: '跟进内容',order: 1,view: 'text', type: 'string',},
        progress: {title: '跟进进度',order: 2,view: 'text', type: 'string',},
        isDeleted: {title: '逻辑删除标志',order: 3,view: 'number', type: 'number',},
        followUpTime: {title: '跟进时间',order: 4,view: 'date', type: 'string',},
        createTime: {title: '创建日期',order: 5,view: 'date', type: 'string',},
    }
  },
};
